#!/usr/bin/python3
# -*- coding:UTF-8 -*-
#Version:0.1
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <IFRFSX@protonmail.com> wrote this file.  As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.   IFRFSX.
# ----------------------------------------------------------------------------
#

import compute

x = eval('0')
f1=open('out.txt', 'a+', encoding='UTF-16')
f1.write('====\n')    
while x == 0:
    print('1.运算方形面积\n2.运算方体体积\n3.运算方体表面积\n4.运算圆形（和球体）的面积（表面积和体积）\n')
    print('输入 /q 可以退出！')
    xz=str(input('输入你的选择：\n'))
    if xz == '1':
        a1 = eval(input('输入长：'))
        a2 = eval(input('输入宽：'))
        
        ax=compute.fangmj(a1, a2)
        print(ax)
        af1=open('out.txt', 'a+', encoding='UTF-16')
        af1.write('长是：'+str(a1)+'\n')
        af1.write('宽是：'+str(a2)+'\n')
        af1.write('本次运算方形面积的结果：'+str(ax)+'\n')
        af1.close()

    elif xz == '2':
        b1 = eval(input('输入长：'))
        b2 = eval(input('输入宽：'))
        b3 = eval(input('输入高：'))
        
        bx=compute.fangtj(b1, b2, b3)
        print(bx)
        bf1=open('out.txt', 'a+', encoding='UTF-16')
        bf1.write('长是：'+str(b1)+'\n')
        bf1.write('宽是：'+str(b2)+'\n')
        bf1.write('高是：'+str(b3)+'\n')
        bf1.write('本次运算方体体积的结果：'+str(bx)+'\n')
        bf1.close()

    elif xz == '3':
        c1 = eval(input('输入长：'))
        c2 = eval(input('输入宽：'))
        c3 = eval(input('输入高：'))

        cx=compute.fangbmj(c1, c2, c3)
        print(cx)
        cf1=open('out.txt', 'a+', encoding='UTF-16')
        cf1.write('长是：'+str(c1)+'\n')
        cf1.write('宽是：'+str(c2)+'\n')
        cf1.write('高是：'+str(c3)+'\n')
        cf1.write('本次运算方体表面积的结果：'+str(cx)+'\n')
        cf1.close()

    elif xz == '4':
        r0 = eval(input('输入半径：'))
        mianji, bmianji, tiji=compute.yuan(r0)
        print(mianji)
        print('\n')
        print(bmianji)
        print('\n')
        print(tiji)
        
        df1=open('out.txt', 'a+', encoding='UTF-16')
        df1.write('圆形或者球体的半径是：'+str(r0)+'\n')
        df1.write('最终结果：'+'\n'+'圆形面积：'+str(mianji)+'\n'+'球体表面积：'+str(bmianji)+'\n'+'球体体积：'+str(tiji)+'\n')
        df1.close()

    elif xz == '/q':
        break
    else:continue
